package com.kanqiubao.kq.activity.ramking;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.angcyo.tablayout.DslTabLayout;
import com.angcyo.tablayout.DslTabLayoutConfig;
import com.angcyo.tablayout.delegate.ViewPager1Delegate;
import com.kanqiubao.kq.R;
import com.kanqiubao.kq.activity.BaseActivity;
import com.kanqiubao.kq.fragment.BaseFragment;
import com.kanqiubao.kq.fragment.NewsFragmentStatePagerAdapter;
import com.kanqiubao.kq.fragment.main.zb.MainZbListFragment;
import com.kanqiubao.kq.fragment.ranking.RankingListFragment;
import com.kanqiubao.kq.utils.AppConfig;
import com.kanqiubao.kq.utils.DebugUntil;
import com.kanqiubao.kq.view.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.ViewPager;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function4;

/**
 * 直播排行
 */
public class RankingMainActivity extends BaseActivity<String> {
    private DslTabLayout mDslTabLayout;

    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        mDslTabLayout = findView(R.id.zb_tab_id);
        int w = (AppConfig.getScreenWidth() - getResources().getDimensionPixelOffset(R.dimen.space_35) * 2) / 3;
        findViewById(R.id.center_root_id).getLayoutParams().width = w + getResources().getDimensionPixelOffset(R.dimen.space_8);
        initFragment();
    }

    @Override
    protected int getActivitylayout() {
        return R.layout.zb_ranking_main_layout;
    }

    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
    }

    @Override
    protected String getTitleText() {
        return "榜单";
    }

    private RankingListFragment mRankingListFragment;

    private void initFragment() {
        List<String> ls = new ArrayList<>();
        ls.add("人气排行榜");
        ls.add("球票排行榜");
        ls.add("贡献排行榜");
        mRankingListFragment = new RankingListFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.zb_page_id, mRankingListFragment);
        ft.commit();
        for (int i = 0; i < ls.size(); i++) {
            View v = LayoutInflater.from(this).inflate(R.layout.layout_txt_view, null);
            ((TextView) v.findViewById(R.id.text_view)).setText(ls.get(i));
            mDslTabLayout.addView(v);
        }
        mDslTabLayout.configTabLayoutConfig(new Function1<DslTabLayoutConfig, Unit>() {
            @Override
            public Unit invoke(DslTabLayoutConfig dslTabLayoutConfig) {
                dslTabLayoutConfig.setOnSelectItemView(new Function4<View, Integer, Boolean, Boolean, Boolean>() {
                    @Override
                    public Boolean invoke(View view, Integer integer, Boolean aBoolean, Boolean aBoolean2) {
                        //选中查数据了
                        return false;
                    }
                });
                return null;
            }
        });
    }
}
